/*  Copyright 2010 Daniel Brasil Magnani
 *  Created on: Dec 20, 2010
 *      Author: daniel
 */

#include <sys/time.h>
#include <stdlib.h>
#include "timer.h"

void Timer::Start() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  start_time = tv.tv_sec+(tv.tv_usec/1000000.0);
}

void Timer::End() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  end_time = tv.tv_sec+(tv.tv_usec/1000000.0);
}

double Timer::get_current_time() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return tv.tv_sec+(tv.tv_usec/1000000.0) - start_time;
}

double Timer::get_end_time() {
  return end_time - start_time;
}
